package com.chunxuan.langquan.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.webkit.WebSettings;

import com.chunxuan.langquan.R;
import com.chunxuan.langquan.base.Base2Activity;
import com.chunxuan.langquan.support.util.HTMLFormat;
import com.chunxuan.langquan.support.view.BaseWebView;

public class WebViewActivity extends Base2Activity {
    BaseWebView webview;
    String adUrl;
    @Override
    protected int getLayoutRes() {
        return R.layout.activity_webview;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        webview=findViewById(R.id.webview);

//        1 //支持javascript
        webview.getSettings().setJavaScriptEnabled(true);
        // 设置可以支持缩放
        webview.getSettings().setSupportZoom(true);
        // 设置出现缩放工具
        webview.getSettings().setBuiltInZoomControls(true);
        //扩大比例的缩放
        webview.getSettings().setUseWideViewPort(true);
        //自适应屏幕
        webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webview.getSettings().setLoadWithOverviewMode(true);
        adUrl=getIntent().getStringExtra("ad_url");
        if(!TextUtils.isEmpty(adUrl)){
            webview.loadDataWithBaseURL(null, HTMLFormat.getNewContent( adUrl ), "text/html", "UTF-8", null);
            webview.loadUrl(adUrl);
        }
    }
}
